const express = require('express');
const app = express();
app.use((request, response, next) => {
  console.log('有人请求服务器2');
  next();
});

app.get('/cars', (request, response) => {
  const car = [
    { id: '001', name: '奔驰', price: 198 },
    { id: '002', name: '奥迪', price: 239 },
    { id: '003', name: '马自达', price: 450 },
  ];
  response.send(car);
});

app.listen(5001, (err) => {
  if (!err) {
    console.log('服务器2启动成功，请求地址为：http://localhost:5001/cars');
  }
});
